<?php

namespace app\test\model;

use think\Model;

class Business extends Model
{
    protected $name = 'business';

    // 定义数据表不存在字段
    protected $append = [
        'gender_text'
    ];

    // public function getGenderAttr($value)
    // {
    //     $genderList = [0 => '保密', 1 => '男', 2 => '女'];

    //     return $genderList[$value];
    // }

    /**
     * 字段获取器 get字段名Attr
     * @param $value 字段值
     * @param $data 某条数据
     */
    public function getGenderTextAttr($data)
    {
        $genderList = [0 => '保密', 1 => '男', 2 => '女'];

        return $genderList[$data['gender']];
    }
}
